<template>
  <!-- 歌单卡片 -->
  <div class="carContainer">
    <!-- 歌单封面 -->
    <div class="cover pointer">
      <img v-lazy="cover + '?param=150y150'" />
      <!-- 播放量 -->
      <div class="playCount">
        <Play theme="outline" size="20" fill="#fff" class="iconfont" />
        <span>{{ formatNumberWithUnit(playCount) }}</span>
      </div>
    </div>
    <!-- 歌单描述 -->
    <p class="pointer">{{ desc }}</p>
  </div>
</template>

<script name="SonglistCard">
import { Play } from '@icon-park/vue-next';
import { formatNumberWithUnit } from '@/utils/formatter';
import { defineComponent } from 'vue';
export default defineComponent({
  name: 'SonglistCar', // 歌单卡片
  components: { Play },
  props: {
    id: {
      type: Number,
      default: 0,
    },
    desc: {
      type: String,
      default: '',
    },
    cover: {
      type: String,
      default: '',
    },
    playCount: '',
  },
  setup() {
    return {
      formatNumberWithUnit,
    };
  },
});
</script>

<style lang="scss" scoped>
// 歌单卡片
.carContainer {
  width: 140px;
  height: 205px;
  overflow: hidden;
  padding: 5px;
  overflow: hidden;

  // 歌单封面
  .cover {
    width: 140px;
    height: 140px;
    transition: box-shadow 0.3s;
    position: relative;
    overflow: hidden;

    &:hover {
      box-shadow: 0 0 4px $main-color;
    }

    img {
      width: 100%;
      height: 100%;
      transition: transform 0.3s;

      &:hover {
        transform: scale(1.1);
      }
    }

    // 播放量
    .playCount {
      width: 100%;
      height: 30px;
      background-color: rgba(0, 0, 0, 0.5);
      backdrop-filter: blur(3px);
      position: absolute;
      bottom: 0;
      left: 0;
      display: flex;
      align-items: center;
      color: #fff;
      font-size: 14px;

      span {
        margin-left: 5px;
      }
    }
  }

  // 歌单描述
  p {
    width: 100%;
    margin: 0;
    margin-top: 5px;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    display: -webkit-box; // 作为弹性伸缩盒子模型显示。
    -webkit-box-orient: vertical; // 设置伸缩盒子的子元素排列方式--从上到下垂直排列
    -webkit-line-clamp: 3; // 显示的行
    color: #333;
    line-height: 1.4em;
  }
}
</style>
